﻿using QuickChat_Service.Repositories.Database;
using QuickChat_Service.Repositories.Repositories.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QuickChat_Service.Repositories.Repositories.Fakes
{
    public class FakeChatSessionRepository : FakeRepository<ChatSession>, IChatSessionRepository
    {
        public void EndChatSession(int sessionId)
        {
            base.Delete(sessionId);
        }

        public ChatSession GetChatSession(int sessionId)
        {
            return base.GetById(sessionId);
        }

        public void AddUserToSession(int userId, int sessionId)
        {
            FakeTalkerRepository repo = new FakeTalkerRepository();
            
            Talker talker = repo.GetById(userId);

            base.GetById(sessionId).Talkers.Add(talker);
        }

        public void Add(int sessionStartersId)
        {
            base.Add(new ChatSession() {
                SessionId = base.GetAll().Count(),
                Messages = new List<Message>(),
                StartTime = DateTime.UtcNow,
                Talkers = new List<Talker>()
            });
        }
    }
}